﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemyShow : MonoBehaviour {

    SpriteRenderer sr;

    public Transform Player;
    void Start()
    {
        sr = GetComponent<SpriteRenderer>();
    }

    void Update()
    {
        if (Player.position.x - transform.position.x >= 0)
        {
            transform.localScale = new Vector3(transform.localScale.x * -1, transform.localScale.y, transform.localScale.z);
            //transform.Rotate(new Vector3(0,180,0));
        }
        else
        {
            transform.localScale = new Vector3(Mathf.Abs(transform.localScale.x) , transform.localScale.y, transform.localScale.z);
            //transform.Rotate(new Vector3(0, 0, 0));
        }
    }

    void OnTriggerEnter(Collider other)
    {
        Debug.Log(11);
        if (other.name.Equals("Collider_EnemyActiveZone"))
        {
            sr.sortingLayerName = "Player";
        }
    }
}
